Finish up gpspilot support. Thanx to Ron Parker!
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 18 Oct 2002 04:22:19 +0000 (04:22 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 18 Oct 2002 04:22:19 +0000 (04:22 +0000)
gpsbabel/README
gpsbabel/gpspilot.c
gpsbabel/reference/gpspilot.pdb [new file with mode: 0644]
gpsbabel/testo

index 608500c3b733e7dc4a550bf32c8eaec269f87cfe..68d86a1d9cfc2445326ab96491113ca07433b3f2 100644 (file)
@@ -122,8 +122,9 @@ THE FORMATS
     GPSPILOT
 
        The file format for GPSPILOT (http://www.gpspilot.com) was provided
-       by Ron Parker.  GPSbabel can currently read gpspilot files, but not
-       write them.
+       by Ron Parker.  The output from this module has been tested with 
+        GPSPilot Tracker v5.05sx, but it is based on reverse-engineering
+        so it may not work with all versions of all GPSPilot products.
 
     MAGNAV
 
index 4d140d78ecc4837629d7cb973cec32a94f1809b9..aebf30d64b97c67e16744b4b098f533e9863344a 100644 (file)
@@ -110,7 +110,6 @@ data_read(void)
                wpt_tmp->description = xstrdup(vdata);
                vdata = vdata + strlen(vdata) + 1;
 
-               vdata = vdata + strlen(vdata) + 1;
                wpt_tmp->shortname = xstrdup(vdata);
                
                waypt_add(wpt_tmp);
@@ -121,41 +120,40 @@ data_read(void)
 
 
 static void
-cetus_writewpt(waypoint *wpt)
+gpspilot_writewpt(waypoint *wpt)
 {
        struct record *rec;
-       static int ct;
-       struct tm *tm;
-
-       rec = xcalloc(sizeof(*rec),1);
-#if FIXME
-       strncpy(rec->ID, wpt->shortname, sizeof(rec->ID));
-       rec->ID[sizeof(rec->ID)-1] = 0;
-       strncpy(rec->name, wpt->description, sizeof(rec->name));
-       rec->name[sizeof(rec->name)-1] = 0;
-
-       if (wpt->creation_time) {
-               tm = gmtime(&wpt->creation_time);
-               rec->min = tm->tm_min;
-               rec->hour = tm->tm_hour;
-               rec->sec = tm->tm_sec;
-               rec->day = tm->tm_mday;
-               rec->mon = tm->tm_mon + 1;
-               rec->year = tm->tm_year - 100;
-       } else {
-               rec->min = 0xff;
-               rec->hour = 0xff;
-               rec->sec = 0xff;
-               rec->day = 0xff;
-               rec->mon = 0xff;
-               rec->year = 0xff;
-       }
+       static int ct = 0;
+       char *vdata;
 
-       pdb_write4(&rec->longitude, wpt->position.longitude.degrees * 10000000.0);
-       pdb_write4(&rec->latitude, wpt->position.latitude.degrees * 10000000.0);
-       pdb_write4(&rec->elevation, wpt->position.altitude.altitude_meters * 100.0);
-#endif
-       opdb_rec = new_Record (0, 0, ct++, sizeof(*rec), (const ubyte *)rec);
+       rec = xcalloc(sizeof(*rec)+46,1);
+       
+       be_write32(&rec->longitude, round(wpt->position.longitude.degrees * 3.6e6));
+       be_write32(&rec->latitude, round(wpt->position.latitude.degrees * 3.6e6));
+       be_write16(&rec->elevation, round(wpt->position.altitude.altitude_meters));
+       be_write16(&rec->magvar, 0 );
+       
+       vdata = (char *)rec + sizeof(*rec);
+       if ( wpt->description ) {
+                strncpy( vdata, wpt->description, 36 );
+                vdata[35] = '\0';
+        }
+        else {
+                vdata[0] ='\0';
+        }
+        vdata += strlen( vdata ) + 1;
+       if ( wpt->shortname ) {
+                strncpy( vdata, wpt->shortname, 9 );
+                vdata[8] = '\0';
+        }
+        else {
+                vdata[0] ='\0';
+        }
+        vdata += strlen( vdata ) + 1;
+       vdata[0] = '\0'; /* long description - currently unsupported */
+       vdata++;
+
+        opdb_rec = new_Record (0, 2, ct++, vdata-(char *)rec, (const ubyte *)rec);            
 
        if (opdb_rec == NULL) {
                fatal(MYNAME ": libpdb couldn't create record");
@@ -169,12 +167,9 @@ cetus_writewpt(waypoint *wpt)
 static void
 data_write(void)
 {
-       int i, ct = waypt_count();
-       struct hdr *htable, *bh;
-        queue *elem, *tmp;
-       extern queue waypt_head;
-        waypoint *waypointp;
-abort();
+        extern queue waypt_head;
+       queue *elem, *tmp;
+
        if (NULL == (opdb = new_pdb())) { 
                fatal (MYNAME ": new_pdb failed\n");
        }
@@ -183,11 +178,17 @@ abort();
        opdb->name[PDB_DBNAMELEN-1] = 0;
        opdb->attributes = PDB_ATTR_BACKUP;
        opdb->ctime = opdb->mtime = time(NULL) + 2082844800U;
-       opdb->type = MYTYPE;  /* poin */
-       opdb->creator = MYCREATOR; /* GpLi */
+       opdb->type = MYTYPE;
+       opdb->creator = MYCREATOR; 
        opdb->version = 0;
+        QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
+               gpspilot_writewpt((waypoint *)elem);
+       }
+       
+       pdb_Write(opdb, fileno(file_out));
 }
 
+
 ff_vecs_t gpspilot_vecs = {
        rd_init,
        wr_init,
diff --git a/gpsbabel/reference/gpspilot.pdb b/gpsbabel/reference/gpspilot.pdb
new file mode 100644 (file)
index 0000000..b4c04f0
Binary files /dev/null and b/gpsbabel/reference/gpspilot.pdb differ
index 4da9e1cacc33446658946e35cf6de129bc442c7b..552d36819ca584b9c07e5e6a5bef9a006610b3b5 100755 (executable)
@@ -134,3 +134,12 @@ ${PNAME} -i magnav -f reference/magnav.pdb -o gpsutil -F ${TMPDIR}/magnavt.gpu
 diff ${TMPDIR}/magnavt.gpu ${TMPDIR}/magnav.gpu
 diff reference/magnavr.gpu ${TMPDIR}/magnav.gpu
 
+# GPSPilot Tracker for PalmOS
+# This test is eerily similar to the NAV Companion test.  In fact, the 
+# converted reference file (magnavr.gpu) is identical.
+${PNAME} -i geo -f geocaching.loc -o gpspilot -F ${TMPDIR}/gpspilot.pdb
+${PNAME} -i gpspilot -f ${TMPDIR}/gpspilot.pdb -o gpsutil -F ${TMPDIR}/gpspilot.gpu
+${PNAME} -i gpspilot -f reference/gpspilot.pdb -o gpsutil -F ${TMPDIR}/gpspil_t.gpu
+diff ${TMPDIR}/gpspil_t.gpu ${TMPDIR}/gpspilot.gpu
+diff reference/magnavr.gpu ${TMPDIR}/gpspilot.gpu
+